import { Directive, HostListener } from '@angular/core';

@Directive({
  selector: '[appLeftkeyListener]'
})
export class LeftkeyListenerDirective {

  isLeftKeyDown: boolean;

  constructor() {
    this.isLeftKeyDown = false;
  }

  @HostListener('window:keydown', ['$event'])
  keydownEvent(event: KeyboardEvent) {
    console.log(event);

    if (event.keyCode === 91) {
      this.isLeftKeyDown = true;
    }
  }

  @HostListener('window:keyup', ['$event'])
  keyupEvent(event: KeyboardEvent) {
    console.log(event);

    if (event.keyCode === 91) {
      this.isLeftKeyDown = false;
    }
  }

}
